<?php
/* 
	[BuyPg] (C) 2010-2011 Buypg
	$Id: IndexAction.class.php 2011-3-30 14:01:53 wufujun $
 */

if (!defined('THINK_PATH')){
	exit('Access Denied');
}

class BeisuAction extends BpAction{
	public function  index(){
		global $_SGLOBAL;
		//继承初始网站系统相关信息
		$pgsys = $this->PublicPgsys;
		//网站系统相关设置在当前控制器私有设置
		$pgsys['sys_set']['set_footer_tools'] = 1; //网站页脚 ”常用工具“ 显示
		$DbBlack = M("NbSite");
		// is the class page
		if(isset($_GET['classid']))
		{
			$strWhere = "class_id = ".$_GET['classid']." and hei = 1 ";
			$DbClass = M("NbClass");
			$arrClass = $DbClass->where("class_id = ".$_GET['classid'])->find();
			if(!$arrClass)
			{
				$this->error("您访问的页面不存在！");
			}
			else
			{
				$strClassName = $arrClass['class_name'];
			}
		}
		else
		{
			$strClassName = "全部分类";
			$strWhere = "hei = 1";
		}

		// is the search page
		if(isset($_GET["key"]))
		{
			$strKeyword = trim($_GET["key"]);
			$strClassName = "搜索被诉网站";
			$strWhere = "hei = 1 and (site_name like '%".$strKeyword."%' or site_link like '%".$strKeyword."%' )  ";
		}

		import("@.ORG.Page"); //导入分页类
		$count = $DbBlack->where($strWhere)->count();    //计算总数
		$p = new Page ( $count, 20 );
		$BlackList = $DbBlack->where($strWhere)->limit($p->firstRow.','.$p->listRows)->order("site_id asc")->select();
		foreach ($BlackList as $key=>$value)
		{
			$BlackList[$key]['site_link'] = urldecode($value['site_link']);
		}
		$p->setConfig('header','篇记录');
		$p->setConfig('prev','<');
		$p->setConfig('next','>');
		$p->setConfig('first','<<');
		$p->setConfig('last','>>');
		$p->setConfig('theme', ' <span>%totalRow% %header% %nowPage%/%totalPage% 页 </span> %first% %upPage% %linkPage% %downPage% %end%');
		$page = $p->show(1);
		
		$this->assign('sys_set' , $pgsys['sys_set']); //网站系统相关设置当前私有设置模板输出
		//定义左侧分类
		$LeftCate = getLeftCategory_blacklist();
		//var_dump($LeftCate);
		
		$this->assign('show_zhanti_menu' , 1); //左侧菜单显示专题
		$this->assign("list", $BlackList);
		$this->assign('page' , $page);
		$this->assign("ClassName", $strClassName);
		//模板输出
		$this->assign('leftcate_blacklist' , $LeftCate);
		$this->display();
		
		
	}

	//Category List Page
	public function BeisuList()
	{
		global $_SGLOBAL;
		//继承初始网站系统相关信息
		$pgsys = $this->PublicPgsys;
		//网站系统相关设置在当前控制器私有设置
		$pgsys['sys_set']['set_footer_tools'] = 1; //网站页脚 ”常用工具“ 显示
		$this->assign('sys_set' , $pgsys['sys_set']); //网站系统相关设置当前私有设置模板输出
		//定义左侧分类
		$LeftCate = getLeftCategory_blacklist();
		//var_dump($LeftCate);
		//模板输出
		$this->assign('leftcate_blacklist' , $LeftCate);
		$this->display();
	}
}
?>
